package com.example.questionsystem.modules.qu.controller;

import com.example.questionsystem.core.api.ApiRest;
import com.example.questionsystem.core.api.controller.BaseController;
import com.example.questionsystem.modules.qu.entity.SubjectSessions;
import com.example.questionsystem.modules.qu.service.SubjectsService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = {"科目API"})
@RestController
@RequestMapping("/subject")
public class SubjectController extends BaseController {

    @Resource
    private SubjectsService subjectsService;

    @GetMapping(value = "/getSubjectList")
    public ApiRest getSubjectList(@RequestParam("projectId") String projectId) {
        List<SubjectSessions> subjectSessionsList = subjectsService.getSubjectSessionsByProjectId(projectId);
        return success("获取成功", subjectSessionsList);
    }

    @GetMapping(value = "/getSubjectById")
    public ApiRest getSubjectById(@RequestParam("subjectId") String subjectId) {
        SubjectSessions subjectSessions = subjectsService.getSubjectSessionsById(subjectId);
        return success("获取成功", subjectSessions);
    }

    @GetMapping(value = "/getSubjectSessionsByProjectId")
    public ApiRest getSubjectSessionsByProjectId(@RequestParam("projectId") String projectId) {
        List<SubjectSessions>  SessionNameList = subjectsService.getSessionName(projectId);
        return success("获取成功", SessionNameList);
    }
    // 获取所有场次信息
    @GetMapping(value = "/getSubjectSessions")
    public ApiRest getSubjectSessions() {
        List<SubjectSessions> subjectSessionsList = subjectsService.getSessionName2();
        return success("获取成功", subjectSessionsList);
    }
    // 根据场次名称获取科目列表
    @GetMapping(value = "/getSubjectBySessionName")
    public ApiRest getSubjectBySessionName(@RequestParam("sessionName") String sessionName) {
        List<SubjectSessions> subjectSessionsList = subjectsService.getSubjectBySessionName(sessionName);
        return success("获取成功", subjectSessionsList);
    }
}
